import cv2
import os
from utils import ReadXml

   
file_dir = r'I:\Temp\Rect\Small'
SuperDir = r'I:\ImgOutput\RoadTest'
SuperFiles = []

if len(SuperFiles) == 0:
    for root, dirs, files in os.walk(file_dir):
        for file in files:
            if file[-1] == 'l':
                img = cv2.imread(root + "\\" + file[:-4] + '.jpg')
                locations = ReadXml(root + "\\" + file)
                for location in locations:
                    cv2.rectangle(img, (location[0], location[1]), (location[2], location[3]), (0, 0, 255), 1)
                img = cv2.resize(img, (600, 600))
                # cv2.namedWindow('%s        jpg' % file[:-3], 0)
                # cv2.moveWindow('%sjpg' % file[:-3], 700, 300)
                cv2.imshow('%sjpg' % file[:-3], img)
                cv2.waitKey(0)
                cv2.destroyAllWindows()
else:
    for name in SuperFiles:
        img = cv2.imread(SuperDir + "\\" + name + ".jpg")
        locations = ReadXml(SuperDir + "\\" + name + ".xml")
        for location in locations:
            cv2.rectangle(img, (location[0], location[1]), (location[2], location[3]), (0, 0, 255), 1)
        cv2.imshow(name, img)
        cv2.waitKey(0)
        cv2.destroyAllWindows()





